package com.example.testleftclose;

import android.app.Activity;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;

import com.swipeclose.SwipeToCloseLayout;
import com.swipeclose.SwipeToCloseLayout.SwipeToCloseLayoutAction;

public abstract class BaseActivity extends Activity implements
		SwipeToCloseLayoutAction {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if (VERSION.SDK_INT >= 19) {
			// 透明状态栏
			getWindow().addFlags(
					WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
		}
		setContentView(getlayoutId());
		findViewById(R.id.test).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				test();
			}
		});
		setTitle(getClass().getName());

		Log.i("TAG", getResources().getDisplayMetrics().widthPixels + "---"
				+ getResources().getDisplayMetrics().heightPixels);
	}

	public abstract int getlayoutId();

	@Override
	public void onCloseAction() {
		finish();
	}

	protected abstract void test();

	@Override
	protected void onPostCreate(Bundle savedInstanceState) {
		super.onPostCreate(savedInstanceState);
		
		SwipeToCloseLayout swipeToCloseLayout = (SwipeToCloseLayout) LayoutInflaterUtils.inflateView(this, R.layout.swipe_to_close_layout);
		swipeToCloseLayout.attachToActivity(this);
		swipeToCloseLayout.setSwipeToCloseLayoutAction(this);
	}

}
